﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;
using qiupeng.Public;
using System.IO;
public partial class SystemManage_username_update : System.Web.UI.Page
{
    Db List = new Db();
    BindDrowDownList list = new BindDrowDownList();
    public static string fjkey;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (this.Session["username"] == null)
        {
            this.Response.Write("<script language=javascript>alert('登陆超时！');window.parent.location = '../main_d.aspx'</script>");
            return;

        }

        if (!Page.IsPostBack)
        {
            this.BindAttribute();
            string sql = "select * from qp_hr_username where id='" + this.List.GetFormatStr(base.Request.QueryString["id"]) + "'";
            OleDbDataReader list = this.List.GetList(sql);
            if (list.Read())
            {
                this.StaffId.Text = list["StaffId"].ToString();
                this.StaffNumer.Text = list["StaffNumer"].ToString();
                this.XingMing.Text = list["XingMing"].ToString();
                this.XingBie.Text = list["XingBie"].ToString();
                this.ShenFen.Text = list["ShenFen"].ToString();
                this.BuMenId.Text = list["BuMenId"].ToString();
                this.BuMen.Text = list["BuMen"].ToString();
                this.Username.Text = list["username"].ToString();
                this.Respon.Text = list["Respon"].ToString();
                this.ResponId.Text = list["ResponId"].ToString();
                this.Iflogin.SelectedValue = list["Iflogin"].ToString();
                this.Remark.Text = list["Remark"].ToString();

                string SQL_GetList1 = "select zhiweileibie from qp_hr_Staff a where a.id=" + Convert.ToInt32(StaffId.Text) + "";
                OleDbDataReader NewReader1 = List.GetList(SQL_GetList1);
                if (NewReader1.Read())
                {
                    zhiweileibie.Text = NewReader1["zhiweileibie"].ToString();

                }
                NewReader1.Close();
            }
            list.Close();

        }
    }
    public void BindAttribute()
    {
        Respon.Attributes.Add("readonly", "readonly");

        Username.Attributes.Add("readonly", "readonly");

        StaffNumer.Attributes.Add("readonly", "readonly");
        XingMing.Attributes.Add("readonly", "readonly");
        XingBie.Attributes.Add("readonly", "readonly");
        ShenFen.Attributes.Add("readonly", "readonly");
        BuMen.Attributes.Add("readonly", "readonly");
        zhiweileibie.Attributes.Add("readonly", "readonly");
        // Button2.Attributes["onclick"] = "javascript:return showwait();";
        Button1.Attributes["onclick"] = "javascript:return chknull();";
    }

    protected void Button2_Click(object sender, EventArgs e)
    {
        Response.Redirect("username.aspx");
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        
        string ResponQx = null;
        string SQL_Check_worknum_qx = "select * from qp_hr_Respon where id='" + ResponId.Text + "'";
        OleDbDataReader MyReader_worknum_qx = List.GetList(SQL_Check_worknum_qx);
        if (MyReader_worknum_qx.Read())
        {
            ResponQx = MyReader_worknum_qx["Perstr"].ToString();
        }
        MyReader_worknum_qx.Close();//对应权限字符串






        string Sql_update = "Update qp_hr_username  Set ResponQx='" + ResponQx + "',Respon='" + List.GetFormatStr(Request.Form["Respon"]) + "',ResponId='" + List.GetFormatStr(ResponId.Text) + "',Iflogin='" + List.GetFormatStr(Iflogin.SelectedValue) + "',Remark='" + List.GetFormatStr(Remark.Text) + "'   where id='" + int.Parse(Request.QueryString["id"]) + "'";
        List.ExeSql(Sql_update);

        List.InsertLog("修改系统用户[" + Username.Text + "]", "用户信息");

        //this.Response.Write("<script language=javascript>alert('提交成功！');window.location.href='username.aspx'</script>");
        this.Response.Write("<script language=javascript>alert('提交成功！');window.opener.location.reload();window.close();</script>");
    }
}
